package com.example.service.impl;

import ch.qos.logback.classic.Logger;
import com.example.entity.PointDefend;
import com.example.entity.PointFlow;
import com.example.entity.training.TrainingPlanDetail;
import com.example.mapp.PointDefendMapp;
import com.example.mapp.PointFlowMapp;
import com.example.service.PointDefendService;
import com.example.service.PointFlowService;
import com.example.util.DateUtils;
import com.example.util.ResultUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 维保人员抽查计划
 */
@Service
public class PointFlowServiceImpl implements PointFlowService {

	private final static Logger logger = (Logger) LoggerFactory.getLogger(PointFlowServiceImpl.class);

	@Autowired
	private PointFlowMapp pointFlowMapp;

	/**
	 * 查询积分流水表
	 * spotCheckPlan
	 * @return
	 */
	@Override
	public Map<String, Object> findList(PointFlow pointFlow) {
		String message = "查询成功";
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			if ((pointFlow.getCurrentPage() + "") != null && (pointFlow.getPageSize() + "") != null) {
				Page<PointFlow> page = PageHelper.startPage(pointFlow.getCurrentPage(), pointFlow.getPageSize());
				List<PointFlow> list = pointFlowMapp.findList(pointFlow);
				map.put("list", list);
				map.put("total", page.getTotal());
			}
		} catch (Exception e) {
			logger.error(e.getMessage());
			message = "查询失败";
			return ResultUtil.returnError(message + e.getMessage(), pointFlow);
		}
		return ResultUtil.returnSuccess(message, map);
	}

}
